package makovo.data;

import makovo.utils.DataAccess;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class User_Register {
	public static boolean registerUser(final String email, final String name, final String lastName, final String secondLastName,
			final String Password, final String state, final int typeUsr, final int stateId, final int cityId, final int locId) {
		boolean register = false;
		ResultSet rs = null;
		try {
			rs = DataAccess.getInstance().execResult("sp_registra_usuario(?,?,?,?,?,?,?,?,?,?)", new ArrayList<String[]>() {
				{
					add(new String[] { "nEmail", email });
					add(new String[] { "nName", name });
					add(new String[] { "nLastName", lastName });
					add(new String[] { "nSecondLastName", secondLastName });
					add(new String[] { "nPassword", Password });
					add(new String[] { "nNombEstado", state });
					add(new String[] { "nTypeUsr", String.valueOf(typeUsr) });
					add(new String[] { "nStateID", String.valueOf(stateId) });
					add(new String[] { "nCityID", String.valueOf(cityId) });
					add(new String[] { "nLocID", String.valueOf(locId) });
				}
			});
			if (rs.next())
				register = true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
		return register;
	}

	public static boolean registerValidator(final String name, final String lastName, final String secondLastName,
			final String state, final String nombEstado, final String phone) {
		boolean register = false;
		ResultSet rs = null;
		try {
			rs = DataAccess.getInstance().execResult("sp_registro_validador(?,?,?,?,?,?)", new ArrayList<String[]>() {
				{
					add(new String[] { "nnombre", name });
					add(new String[] { "napellidoPat", lastName });
					add(new String[] { "napellidoMat", secondLastName });
					add(new String[] { "nidEstado", state });
					add(new String[] { "nestado", nombEstado });
					add(new String[] { "ntelefono", phone });
				}
			});
			if (rs.next())
				register = true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			System.out.println(e.getMessage());
		}
		return register;
	}

}
